﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace logicunivesityinventorystore.Store
{
    public partial class TrendAnalysisReportWindow : System.Web.UI.Page
    {
        SqlConnection cn;
        SqlCommand cm;
        SqlDataAdapter da;
        PerDEPTperCategoryDataSet ds;
        SqlCommandBuilder cmb;
        protected void Page_Load(object sender, EventArgs e)
        {
            crystalReport();
        }
        private void crystalReport()
        {
            //InventoryStoreDBConnectionString
            string conS = System.Configuration.ConfigurationManager.ConnectionStrings["InventoryStoreData"].ConnectionString;
            cn = new SqlConnection(conS);
            cm = new SqlCommand();
            cm.Connection = cn;
            string departmentCode = "COMM"; //Request.QueryString["departmentCode"].ToString();
            cm.CommandText = "SELECT     dbo.Employee.EmployeeName, dbo.Employee.Departmentcode, dbo.Department.DepartmentCode AS Expr1, dbo.Department.DepartmentName, " +
                     " dbo.Category.CategoryID, dbo.Category.CategoryName, dbo.RetrivalListDetails.ItemCode, dbo.RetrivalListDetails.ActualQty, dbo.RetrivalList.RetrivalListID, " +
                     " dbo.RetrivalList.Departmentcode AS Expr2, dbo.RetrivalList.LastModified, dbo.Item.ItemCode AS Expr3, dbo.Item.CategoryID AS Expr4, dbo.Item.Description, " +
                     " dbo.RetrivalList.Status" +
                     " FROM dbo.RetrivalList INNER JOIN" +
                     "  dbo.Department INNER JOIN" +
                    "  dbo.Employee ON dbo.Department.ClerkID = dbo.Employee.EmployeeID ON dbo.RetrivalList.Departmentcode = dbo.Department.DepartmentCode INNER JOIN" +
                     " dbo.RetrivalListDetails ON dbo.RetrivalList.RetrivalListID = dbo.RetrivalListDetails.RetrivalListID INNER JOIN" +
                     " dbo.Item INNER JOIN" +
                     " dbo.Category ON dbo.Item.CategoryID = dbo.Category.CategoryID ON dbo.RetrivalListDetails.ItemCode = dbo.Item.ItemCode ";
            da = new SqlDataAdapter(cm);
            ds = new PerDEPTperCategoryDataSet();
            da.Fill(ds, "PerDepartmentPerCategory");
            PerItemByDepartment rrC = new PerItemByDepartment();
            rrC.SetDataSource(ds);
            CrystalReportViewer1.ReportSource = rrC;
        }
    }
}